﻿using System;
using System.Collections.Generic;
using System.Diagnostics.Contracts;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using PhysicsEngine.Common;
using PhysicsEngine.Dynamics;

namespace PhysicsEngine.Collision.Shapes
{
  public class Circle : IShape
  {
    public float Radius { get; private set; }
    public Vector2 Position { get; private set; }

    public Circle(float radius, Vector2 position)
    {
      Contract.Requires<ArgumentException>(radius > 0, "Radius must be greater than 0.");
      Contract.Ensures(Radius == radius);
      Contract.Ensures(Position == position);

      Radius = radius;
      Position = position;
    }

    [ContractInvariantMethod]
    private void ObjectInvariant()
    {
      Contract.Invariant(Radius > 0);
    }

    public MassData ComputeMass(float density)
    {
      Contract.Ensures(Contract.Result<MassData>().Mass == density * (float)Math.PI * Radius * Radius);

      return new MassData(density * (float)Math.PI * Radius * Radius);
    }

    public void Render()
    {
      throw new NotImplementedException();
    }
  }
}
